lexer grammar AnalexLexer;
 
options {
  language = Java;
}

tokens {


}

@lexer::header {
  package Practica6.Ambiguedad;
}

@lexer::members {
private ArrayList<String> errors = new ArrayList<String>();
	public void displayRecognitionError(String[] tokenNames, RecognitionException e) {
		String hdr = getErrorHeader(e);
		String msg = getErrorMessage(e, tokenNames);
		errors.add(hdr + " " + msg);
	}
	 
	public ArrayList<String> getErrors() {
	  return errors;
	}
}
 
fragment SALTO_LINEA:  ('\r' '\n' | '\r' | '\n');
fragment DIGITO: '0'..'9';
fragment LETRA: 'A'..'Z' | 'a'..'z' | '_';

DATO_TIPO 
    :   'boolean'
    |   'char'
    |   'byte'
    |   'short'
    |   'int'
    |   'long'
    |   'float'
    |   'double'
    ;

 
KEYWORD_VOID
  : 'void'
  ;
  
KEYWORD_IF
  : 'if'
  ;
  
KEYWORD_ELSE
  : 'else'
  ;
  
KEYWORD_WHILE
  : 'while'
  ;
  
KEYWORD_FOR
  : 'for'
  ;
  
KEYWORD_BREAK
  : 'break'
  ; 


COMENTARIO_LINEA : '//' (options { greedy=false;}:.)* SALTO_LINEA {skip();};
COMENTARIO_BLOQUE: '/*' ( options {greedy=false;} : . )* '*/' {skip();};
BLANCO: (' ' | '\t' | SALTO_LINEA) {skip();};
NUMERO : (OP_SUB)? (DIGITO)+('.'(DIGITO)+)?;
ID: LETRA (LETRA | DIGITO)*;
CARACTER: '\'' (LETRA | DIGITO) '\'';
STRING: '\"' (options { greedy=false; }:.)* '\"';
 
OP_SUM: '+';
OP_SUB: '-';
OP_DIV: '/';
OP_MULT: '*';
OP_ME: '<';
OP_MEI: '<=';
OP_MA: '>';
OP_MAI: '>=';
OP_INC: '++';
OP_DEC: '--';
OP_ASSIGN: '=';
OP_IGUAL: '==';
OP_DISTINTO: '!=';
OP_AND: '&&';
OP_OR: '||';
LEFT_PAREN: '(';
RIGHT_PAREN: ')';
OP_BRACKET: '[';
CP_BRACKET: ']';
LEFT_BRACE: '{';
RIGHT_BRACE: '}';
OP_EXCLA: '!';
COMA: ',';
SEPARADOR: ';';
OP_QUESTIONMARK: '?';
OP_COLON: ':'; 